'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#作者：cacho_37967865
#博客：https://blog.csdn.net/sinat_37967865
#文件：pandas_excel.py
#日期：2019-12-13
#备注：本文主要介绍了pandas处理excel。     
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

import pandas as pd
from pycacho.cachobase.deal_threading import deal_list
import threading
import time


def split_excel(file,n):
    data = pd.read_excel(file)
    new_df = []
    rows = data.shape[0]         # 获取行数, shape[1]获取列数
    for i in range(0,rows,n):
        new_df.append(data[i:i+n])
    return new_df


def new_excel(df):
    df.to_excel('E:\zenglingwei\\test\\' + threading.currentThread().name + ".xls", sheet_name='sheet', index=False)


# 统计重复数据
def repeat_data(file,column):
    df = pd.read_excel(file,dtype='object')
    repeat = df[df[column].duplicated(keep=False)]
    #print(repeat[column])
    repeat.to_excel('E:\zenglingwei\\test\\' + 'split2' + ".xls", sheet_name='split', index=False)


if __name__ == '__main__':
    sTime = time.time()
    #df = split_excel('E:\zenglingwei\\test\\split.xlsx',30000)
    #deal_list(df,new_excel)
    repeat_data('E:\zenglingwei\\test\\Thread-2.xls','blacklistValue')
    eTime = time.time()
    s = eTime - sTime
    print('总共花费的时间为：%.2f秒' % (s))
